package com.czkevin.guicontrolsapi;

import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Arrays;

public class ItemUtils {

    public static ItemStack putMeta(ItemStack stack, String name, String... lore) {
        return putMeta(stack, true, name, lore);
    }

    public static ItemStack putMeta(ItemStack stack, boolean doClone, String name, String... lore) {
        if(stack == null) return null;
        ItemMeta m = stack.getItemMeta();
        m.setUnbreakable(true);
        m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        m.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
        m.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
        m.setDisplayName(name);
        m.setLore(Arrays.asList(lore));
        if(doClone) {
            ItemStack ret = stack.clone();
            ret.setItemMeta(m);
            return ret;
        } else {
            stack.setItemMeta(m);
            return stack;
        }
    }

}
